                    

<div class="page-header">
    <h1>
        My Team
        <small>
            <i class="icon-double-angle-right"></i>
            Add New Team
        </small>
    </h1>
</div>
                    
<?php 

if ($this->msg != "") {
    ?>
    <div class="alert alert-info">
        <button type="button" class="close" data-dismiss="alert">
            <i class="icon-remove"></i>
        </button>

        <strong>
            <i class="icon-ok"></i>
        </strong>

        <?php echo $this->msg; ?>, go to <a href="login">Login Page</a>
        <br />
    </div>
    <?php
}
if ($this->errmsg != "") {
    ?>
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">
            <i class="icon-remove"></i>
        </button>

        <strong>
            <i class="icon-remove"></i>

        </strong>

        <?php echo $this->errmsg; ?>
        <br />
    </div>
<?php
}
?>

    <div class="row">
        <div class="col-xs-11">
            <form id="formAdd" class="form-horizontal" role="form" action="" method="post" onsubmit="return submitForm()">
                <div class="col-sm-12">

                    

                    <div class="col-sm-6">
                    <h4>
                    <i class="icon-credit-card"></i>
                      FX Trade Point ID Details
                    </h4>
                        <br>
                        <div class="form-group">
                            <label class="col-sm-6" for="sponsorCode"> Sponsor ID </label>

                            <div class="col-sm-12">
                                <input type="text" id="sponsorCode" name="sponsorCode" placeholder="Sponsor ID" class="col-xs-8" value="<?php if (isset( $this->data['sponsorCode'] )) { echo $this->data['sponsorCode'];} ?>" required />
                                

                            </div>

                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="sponsorName"> Sponsor Name </label>

                            <div class="col-sm-12">
                                <input type="text" id="sponsorName" name="sponsorName" placeholder="Sponsor Name" class="col-xs-8" value="<?php if (isset( $this->data['sponsorName'] )) { echo $this->data['sponsorName'];} ?>" required />
                            </div>

                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="upperCode"> Upperlink ID </label>

                            <div class="col-sm-12">
                                <input type="text" id="upperCode" name="upperCode" placeholder="Upperlink ID" class="col-xs-8" value="<?php if (isset( $this->data['upperCode'] )) { echo $this->data['upperCode'];} ?>" required />
                            </div>

                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="upperName"> Upperlink Name </label>

                            <div class="col-sm-12">
                                <input type="text" id="upperName" name="upperName" placeholder="Upperlink Name" class="col-xs-8" value="<?php if (isset( $this->data['upperName'] )) { echo $this->data['upperName'];} ?>" required />
                            </div>

                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="slpos"> Position </label>

                            <div class="col-sm-12">
                                <?php
                                $pos = $this->data["pos"];

                                if ($pos != ""){
                                    $readOnly = "disabled";
                                }
                                ?>
                                <select class="col-xs-8" id="slpos" name="slpos" <?php echo $readOnly;?>>
                                    <option value="1" <?php if ($pos == 1) echo "selected";?>>LEFT</option>
                                    <option value="2" <?php if ($pos == 2) echo "selected";?>>RIGHT</option>
                                </select>
                                <input type="hidden" id="pos" name="pos" value="<?php echo $pos;?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="password"> Password </label>

                            <div class="col-sm-12">
                                <input type="password" id="pass" name="pass" placeholder="Password" class="col-xs-8" required />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="name"> Confirm Password </label>

                            <div class="col-sm-12">
                                <input type="password" id="confPass" name="confPass" placeholder="Confirm Password" class="col-xs-8" required />
                            </div>
                        </div>

                    </div>

                    <div class="col-sm-6">
                        <h4>
                    <i class="icon-user"></i>
                      Personal Details
                    </h4>
                        <br>
                        <div class="form-group">
                            <label class="col-sm-6" for="firstName"> First Name </label>

                                <div class="col-sm-12">
                                   <input type="text" id="firstName" name="firstName" placeholder="First Name" class="col-xs-8" value="<?php if (isset( $this->data['firstName'] )) { echo $this->data['firstName'];} ?>" required />
                                </div>

                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="lastName">Last Name</label>
                            <div class="col-sm-12">
                                <input type="text" id="lastName" name="lastName" placeholder="Last Name" class="col-xs-8" value="<?php if (isset( $this->data['lastName'] )) { echo $this->data['lastName'];} ?>" required />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="address"> Address </label>

                            <div class="col-sm-8">
                                <textarea id="address" name="address" class="autosize-transition form-control" placeholder="Address" required><?php if (isset( $this->data['address'] )) { echo $this->data['address'];} ?></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="city"> City </label>

                            <div class="col-sm-12">
                                <input type="text" id="city" name="city" placeholder="City" class="col-xs-8" value="<?php if (isset( $this->data['city'] )) { echo $this->data['city'];} ?>" required />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="name"> Country </label>

                            <div class="col-sm-12">
                                <select class="col-xs-8 chosen-select" id="country" name="country" data-placeholder="Choose a Country...">
                                    <option value="">&nbsp;</option>

                                    <?php
                                    for ($x=0; $x<count($this->countryList); $x++){
                                        echo "<option value='".$this->countryList[$x]["code"]."'>".$this->countryList[$x]["name"]."</option>\n";
                                    }
                                    ?>

                                    </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="mobile"> Mobile </label>

                            <div class="col-sm-12">
                                <input type="text" id="mobile" name="mobile" placeholder="Mobile" class="col-xs-8" value="<?php if (isset($this->data['mobile'])) { echo $this->data['mobile']; } ?>" required />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-6" for="email"> Email </label>

                            <div class="col-sm-12">
                                <input type="text" id="email" name="email" placeholder="Email" class="col-xs-8" value="<?php if (isset( $this->data['email'] )) { echo $this->data['email'];} ?>" required />
                            </div>
                        </div>

                        

                    </div>

                    <div class="col-sm-12 clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <label class="middle">
                                <input name="cbAgree" id="cbAgree" type="checkbox" class="ace" />
                                <span class="lbl"> I Accept The <a href="#">Terms and Conditions</a></span>
                                </label>

                            </div>
                            <br><br>
                            <div class="col-md-offset-3 col-md-9">
                                <button class="btn btn-success" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    Submit
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    Reset
                                </button>
                                <input type="hidden" id="sponsorId" name="sponsorId" value="<?php if (isset( $this->data['sponsorId'] )) { echo $this->data['sponsorId'];} ?>"/>
                                <input type="hidden" id="upperId" name="upperId" value="<?php if (isset( $this->data['upperId'] )) { echo $this->data['upperId'];} ?>"/>

                            </div>

                        </div>

                    
            </div><!-- /span -->

                
            </form>
    </div>

</div>

<script>
    jQuery(function($) {
        $('.chosen-select').chosen();


        $('#modal-form').on('shown.bs.modal', function() {
            $(this).find('.chosen-container').each(function() {
                $(this).find('a:first-child').css('width', '210px');
                $(this).find('.chosen-drop').css('width', '210px');
                $(this).find('.chosen-search input').css('width', '200px');
            });
        });

        $('textarea[class*=autosize]').autosize({append: "\n"});


    });



    function submitForm(){

        var pass = $('#pass').val();
        var pass2 = $('#confPass').val();
        var firstName = $('#firstName').val().trim();
        var msg = "";

        if (pass != pass2) msg += "Password do not match<br>";
        if (firstName == "") msg += "Please fill First Name Column<br>";

        if (msg != ""){
            bootbox.dialog({
                    message: "<span class='bigger-110'>"+msg+"</span>",
                    buttons:
                    {
                            "button" :
                             {
                                    "label" : "<i class='icon-ok'></i> Ok",
                                    "className" : "btn-sm btn-primary",
                                    //"callback": function() {
                                            //Example.show("great success");
                                    //}
                            }
                    }
            });

            return false;
        }

        if ($('#cbAgree').prop('checked') == false){
            bootbox.dialog({
                    message: "<span class='bigger-110'>You must accept the Terms and Conditions</span>",
                    buttons:
                    {
                            "button" :
                             {
                                    "label" : "<i class='icon-ok'></i> Ok",
                                    "className" : "btn-sm btn-primary",
                                    //"callback": function() {
                                            //Example.show("great success");
                                    //}
                            }
                    }
            });
            return false;
        }


        return true;

    }

    function getSponsor(){

            document.getElementById("getSp").innerHTML = "Fetching...";

        $.ajax({
            type: 'GET',
            dataType: 'text',
            url: '<?php echo $this->url() ?>Index/getsponsor?spId=<?php echo $this->spId;?>',
            success: function(result){

                        if (result != ""){
                            var arrRes = result.split("#");
                            var arrSponsor = arrRes[0].split("|");
                            var arrParent = arrRes[1].split("|");
                            var pos = (arrParent[3] == 1) ? 2 : 1;

                            $('#sponsorId').val(arrSponsor[0]);
                            $('#sponsorCode').val(arrSponsor[1]);
                            $('#sponsorName').val(arrSponsor[2]);

                            $('#upperId').val(arrParent[0]);
                            $('#upperCode').val(arrParent[1]);
                            $('#upperName').val(arrParent[2]);
                            $('#pos').val(pos);

                        }

                        document.getElementById("getSp").innerHTML = "Get Sponsor";

                 }
            });
    }
    </script>